home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / 4dostool / mov_numb.zip / MOV&NUMB.BAK < prev    next >
Text File  |  1993-06-02  |  1KB  |  23 lines

  1. @echo off
  2. REM Batch program for 4DOS to move and renumber files to a new subdirectory.
  3. REM by John D. Cook June 2, 1993
  4. REM Written to store new articles from Usenet news group comp.robotics
  5. REM in sequentally numbered files. Only works with files that end in ".txt".
  6.  
  7. REM  Cannot have a file not ending in a number, will cause nasty problems
  8. REM   since no number will be detected and files will get overwritten.
  9. if exist %1.txt rename %1.bad
  10. if exist %2\%1.txt rename %2\%1.bad
  11.  
  12. REM First get the number of the highest numbered file in storage, this is max.
  13. set namelen=%@len[%1]
  14. pushd %2
  15. for %a in (%1*.txt) if exist %@name[%a].txt (set a=%@name[%a] ^ set max=%@substr[%a,%namelen,3])
  16. echo %max
  17.  
  18. REM Now set new to the next highest available number.
  19. set new=%@eval[%max + 1]
  20. popd
  21.  
  22. REM Last, move each new file to storage, updating the number so they are sequential.
  23. for %a in (%1*.txt) if exist %@name[%a].txt (set a=%@name[%a] ^ set curr=%@substr[%a,%namelen,3] ^ move %1%curr.txt %2\%1%new.txt ^ set new=%@eval[%new + 1])